//
//  SYJVisitorViewController.swift
//  weibo
//
//  Created by 孙英建 on 16/4/16.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class SYJVisitorViewController: UITableViewController {

    // 判断是否登录
    var isLogin: Bool = SYJUserAccountTools.sharedTools.isLogin
    // 访客视图
    var visitorView: SYJVisitorView?
    
    
    override func loadView() {
        
        isLogin == true ? super.loadView() : setUpVisitorView()
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }

    // 设置navagationitem
    func setNavgationItem(){
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
    }

    // 设置访客视图
    func setUpVisitorView(){
        
        setNavgationItem()
        
        visitorView = SYJVisitorView()
        visitorView?.clickButton = {
            self.login()
        }
        
        view = visitorView
    }
    
    // 左右按钮的点击事件
    @objc private func login(){
        
        let oauthVc = SYJOauthViewController()
        
        self.presentViewController(UINavigationController(rootViewController: oauthVc), animated: true, completion: nil)
    }

}






